Skip to content

Move between images with the arrow keys - #3

Merged
paulglover merged 1 commit into
mainfrom
arrow-keys
Aug 10, 2026
Merged

Move between images with the arrow keys#3
paulglover merged 1 commit into
mainfrom
arrow-keys

Conversation

@paulglover

Copy link
Copy Markdown
Owner

and draw another image, returns to the entry screen — the same two outcomes a swipe produces.

A mouse has no swipe. A desktop browser can drag, but swipeOutcome's thresholds are written for a finger (a fifth of the viewport, or a flick at a finger's speed) and a mouse produces neither reliably.

  • keyOutcome in core.js returns swipeOutcome's vocabulary, and both routes now run through Viewer.commit, so a key press and a gesture cannot drift into different behaviour.
  • stays unbound — not for the reason swipe-up is (a keyboard collides with no system gesture) but because / already mean "another image".
  • Modified (Cmd/Ctrl/Alt/Shift) and auto-repeating arrows are left alone; a held key would abort each load to start the next.
  • dismiss() now takes the outcome immediately when no photo is on screen. A display:none element never fires transitionend, so it would otherwise sit through the full 400 ms timeout. This also gives the error state a way out that is not a page reload — it had none, since onPointerDown refuses to start a gesture on a hidden photo.

Four tests in core.test.mjs cover the mapping, including that every outcome a key produces is one commit already handles. The DOM wiring (guards, preventDefault, which edge the image leaves by, the hidden-photo path) was checked against a stub DOM outside the repo; core.test.mjs stays DOM-free by design.

Not verified in a real browser — no automation on this machine, and the repo has no npm.

🤖 Generated with Claude Code

https://claude.ai/code/session_01T4oAqvh4CPXFK2uWJnSXpa

A mouse has no swipe. A desktop browser can drag, but swipeOutcome's
thresholds are written for a finger — a fifth of the viewport, or a flick at a
finger's speed — and a mouse produces neither reliably, so the viewer reads as
inert on a desktop.

← and → draw another image, ↓ returns to the entry screen: the same two
outcomes a swipe produces, deliberately, so keyOutcome returns swipeOutcome's
vocabulary and both routes run through the new Viewer.commit rather than each
building its own dismissal.

↑ stays unbound. Not for the reason swipe-up is — a keyboard collides with no
system gesture — but because ← and → already mean "another image".

Two smaller things fall out of it. dismiss() now takes the outcome immediately
when there is no photo on screen, because a display:none element never fires
transitionend and would otherwise sit through the full 400 ms timeout; that
also gives the error state a way out that is not a page reload, which it did
not have before, since onPointerDown refuses to start a gesture on a hidden
photo. And modified or auto-repeating arrows are left alone: a held key would
abort each load to start the next.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01T4oAqvh4CPXFK2uWJnSXpa
@paulglover
paulglover merged commit eec8b96 into main Aug 10, 2026
1 check passed
@paulglover
paulglover deleted the arrow-keys branch August 10, 2026 21:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant